//
//  CPSCServiceListContentNormlView.m
//  CollTest
//
//  Created by codew on 9/12/21.
//

#import "CPSCServiceListContentNormlView.h"
#import "CPSCServiceMarkVerticalView.h"
#import "CPSCServiceMarkTransverseView.h"
@interface CPSCServiceListContentNormlView ()

// Super ====================================================
/** 用户信息 */
@property (nonatomic, strong) UIView * viewSuperUser;
/** 竖向标签 */
@property (nonatomic, strong) UIView * viewSuperMarkVertical;
/** 横向标签 */
@property (nonatomic, strong) UIView * viewSuperMarkTransverse;
//====================================================
/** 头像 */
@property (nonatomic, strong) UIImageView * imageViewUser;
/** 头像-标签图片 */
@property (nonatomic, strong) UIImageView * imageViewMark;
/** 商品-名称 */
@property (nonatomic, strong) UILabel * lblCommodityName;
/** 商品-价格 */
@property (nonatomic, strong) UILabel * lblCommodityPrice;
/** 商品-单位 */
@property (nonatomic, strong) UILabel * lblCommodityUnit;
/** 竖向标签 */
@property (nonatomic, strong) CPSCServiceMarkVerticalView * viewMarkVertical;
/** 横向标签 */
@property (nonatomic, strong) CPSCServiceMarkTransverseView * viewMarkTransverse;


@end

@implementation CPSCServiceListContentNormlView


- (instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame]){
        
        [self initSubviews];
        [self makeContraints];
    }
    return self;
}


- (void)initSubviews
{
    
    [self addSubview:self.viewSuperUser];
    [self addSubview:self.viewSuperMarkVertical];
    [self addSubview:self.viewSuperMarkTransverse];
    //===
    [self.viewSuperUser addSubview:self.imageViewUser];
    [self.viewSuperUser addSubview:self.imageViewMark];
    [self addSubview:self.lblCommodityName];
    [self addSubview:self.lblCommodityPrice];
    [self addSubview:self.lblCommodityUnit];
    [self.viewSuperMarkVertical addSubview:self.viewMarkVertical];
    [self.viewSuperMarkTransverse addSubview:self.viewMarkTransverse];
    
    [self deBugUI];
}


- (void)makeContraints {
    
    [self.viewSuperUser mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.height.width.mas_equalTo(60);
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(12);
    }];
    
    [self.imageViewUser mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.mas_equalTo(0);
    }];
    [self.imageViewMark mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.bottom.mas_equalTo(0);
        make.height.width.mas_equalTo(14);
    }];
    
    
    [self.viewSuperMarkVertical mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.height.mas_equalTo(56);
        make.top.mas_equalTo(14);
        make.right.mas_equalTo(-20);
        make.left.equalTo(self.viewSuperUser.mas_right).offset(12);
    }];
    
    [self.lblCommodityName mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.viewSuperUser.mas_bottom).offset(12);
        make.left.equalTo(self.viewSuperUser);
        make.right.mas_equalTo(-10);
    }];
    
    [self.viewSuperMarkTransverse mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.lblCommodityName.mas_bottom).offset(6);
        make.left.equalTo(self.viewSuperUser);
        make.right.mas_equalTo(-10);
        make.height.mas_equalTo(14);
    }];
    
    [self.lblCommodityPrice mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.height.mas_equalTo(22);
        make.left.mas_equalTo(10);
        make.bottom.mas_equalTo(-12);
    }];
    
    [self.lblCommodityUnit mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.lblCommodityPrice.mas_right).offset(2);
        make.bottom.equalTo(self.lblCommodityPrice.mas_bottom).offset(-3);
        make.height.mas_equalTo(15);
    }];
    [self.viewMarkVertical mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.mas_equalTo(0);
    }];
    
    [self.viewMarkTransverse mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.mas_equalTo(0);
    }];
    
}

- (void)deBugUI
{
    
//    self.viewSuperUser.backgroundColor = kCPSCRandomColor;
    self.viewSuperMarkVertical.backgroundColor = kCPSCRandomColor;
    self.viewSuperMarkTransverse.backgroundColor = kCPSCRandomColor;
//    self.lblCommodityName.backgroundColor = kCPSCRandomColor;
    
    NSString * name = @"有限公有限公司注册有限公司注册有限公司注司注册有限公";
    NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];
    paragraphStyle.lineSpacing = 5;
    NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
    [attributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName];
    self.lblCommodityName.attributedText = [[NSAttributedString alloc] initWithString:name attributes:attributes];
    
    
    self.lblCommodityPrice.text = @"645";
    self.lblCommodityUnit.text = @"万";
    
    self.imageViewMark.image = [UIImage imageNamed:@"vip"];
    NSURL * url = [NSURL URLWithString:@"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fdingyue.ws.126.net%2FfU7Z80T4ZBwznHpwrZYuwV9NL124Dtc8lr82YqVPEIltK1488783904344.jpg&refer=http%3A%2F%2Fdingyue.ws.126.net&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1634043996&t=654ef7f4fc02b10206907a974d5dc7d5"];
    [self.imageViewUser sd_setImageWithURL:url placeholderImage:nil];
    
    NSArray * mark1 = @[
        @"服务专业",
        @"办事效率",
        @"尽职尽责"
    ];
    
    [self.viewMarkVertical updateViewWithItems:mark1];
    [self.viewMarkTransverse updateViewWithItems:mark1];
    
}

- (void)updateViewWithItem:(id)item
{
    
}
#pragma mark - Getter Setter
- (UIView *)viewSuperUser
{
    
    if (!_viewSuperUser) {
        
        UIView * view = [[UIView alloc] init];
        view.backgroundColor = [UIColor whiteColor];
        view.clipsToBounds = YES;
        
        _viewSuperUser = view;
    }
    return _viewSuperUser;
}
- (UIView *)viewSuperMarkVertical
{
    
    if (!_viewSuperMarkVertical) {
        
        UIView * view = [[UIView alloc] init];
        view.backgroundColor = [UIColor whiteColor];
        view.clipsToBounds = YES;
        
        _viewSuperMarkVertical = view;
    }
    return _viewSuperMarkVertical;
}
- (UIView *)viewSuperMarkTransverse
{
    
    if (!_viewSuperMarkTransverse) {
        
        UIView * view = [[UIView alloc] init];
        view.backgroundColor = [UIColor whiteColor];
        view.clipsToBounds = YES;
        
        _viewSuperMarkTransverse = view;
    }
    return _viewSuperMarkTransverse;
}

/** 头像 */
- (UIImageView *)imageViewUser
{
    if (!_imageViewUser) {
        
        UIImageView * imageViewIcon = [[UIImageView alloc] init];
        imageViewIcon.contentMode = UIViewContentModeScaleAspectFill;
        imageViewIcon.layer.cornerRadius = 30;
        imageViewIcon.layer.masksToBounds = YES;
        
        _imageViewUser = imageViewIcon;
    }
    return _imageViewUser;
}
/** 头像-标签图片 */
- (UIImageView *)imageViewMark
{
    if (!_imageViewMark) {
        
        UIImageView * imageViewIcon = [[UIImageView alloc] init];
        imageViewIcon.contentMode = UIViewContentModeScaleAspectFill;
                        
        _imageViewMark = imageViewIcon;
    }
    return _imageViewMark;
}
/** 商品-名称 */
- (UILabel *)lblCommodityName
{
    if (!_lblCommodityName) {
        
        UILabel * lblZy = [[UILabel alloc] init];
        lblZy.textColor = [UIColor colorWithHexString:@"#222222"];
        lblZy.font = [UIFont systemFontOfSize:15 weight:1];
        lblZy.textAlignment = NSTextAlignmentLeft;
        lblZy.numberOfLines = 2;
        _lblCommodityName = lblZy;
    }
    
    return _lblCommodityName;
}
/** 商品-价格 */
- (UILabel *)lblCommodityPrice
{
    if (!_lblCommodityPrice) {
        
        UILabel * lblZy = [[UILabel alloc] init];
        lblZy.textColor = [UIColor colorWithHexString:@"#EC5330"];
        lblZy.font = [UIFont systemFontOfSize:18 weight:1];
        lblZy.textAlignment = NSTextAlignmentLeft;
        
        _lblCommodityPrice = lblZy;
    }
    
    return _lblCommodityPrice;
}
/** 商品-单位 */
- (UILabel *)lblCommodityUnit
{
    if (!_lblCommodityUnit) {
        
        UILabel * lblZy = [[UILabel alloc] init];
        lblZy.textColor = [UIColor colorWithHexString:@"#EC5330"];
        lblZy.font = [UIFont systemFontOfSize:11];
        lblZy.textAlignment = NSTextAlignmentLeft;
        
        _lblCommodityUnit = lblZy;
    }
    
    return _lblCommodityUnit;
}

- (CPSCServiceMarkVerticalView *)viewMarkVertical
{
    
    if (!_viewMarkVertical) {
        
        CPSCServiceMarkVerticalView * view = [[CPSCServiceMarkVerticalView alloc] init];
        view.backgroundColor = [UIColor whiteColor];
        view.clipsToBounds = YES;
        
        _viewMarkVertical = view;
    }
    return _viewMarkVertical;
}

- (CPSCServiceMarkTransverseView *)viewMarkTransverse
{
    
    if (!_viewMarkTransverse) {
        
        CPSCServiceMarkTransverseView * view = [[CPSCServiceMarkTransverseView alloc] init];
        view.backgroundColor = [UIColor whiteColor];
        view.clipsToBounds = YES;
        
        _viewMarkTransverse = view;
    }
    return _viewMarkTransverse;
}


@end
